package com.kethink;

import java.math.BigInteger;
import java.util.*;

/**
 * @Description create by xuxiaojun
 * date: 2018/12/25
 * Time: 21:30
 */
public class LeeCode_806 {

    public static void main(String[] args){

       int[] widths = new int[]{10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
       String S = "abcdefghijklmnopqrstuvwxyz";

        System.out.println(Arrays.toString(numberOfLines(widths,S)));
    }

    public static int[] numberOfLines(int[] widths, String S){

       int x=1,y=0;

       char[] chars = S.toCharArray();

       for(int i = 0 ; i< chars.length ; i++){
           if((y + widths[chars[i] - 'a']) > 100){
               x++;
               y = 0;
           }
           y += widths[chars[i] - 'a'];
       }

        return new int[]{x,y};
    }
}
